<template>
  <div>
    <h1><img src="@assets/image/157793128909842388.png" alt=""></h1>
    <div class="bottom">
      <div class="con" v-for="item in lives" :key="item.id" @click="enterDetail(item.id)">
        <img  v-lazy="item.pic" alt="">
        <div class="c-bttom">
          <p>
            {{item.name}}
          </p>
          <div class="evaluate">
            {{item.tags}}
          </div>
          <div class="price">
            <div class="pr-left">
              <span class="money">{{item.minPrice | currency}}</span>
              <span class="volume">10+评价</span>
            </div>
            <van-icon name="add" color="#f66" size="30" @click.stop="clickAddCart(item)" />
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { currency } from '@filters'
import { Toast } from 'vant'


export default {
  props: {
    lives: {
      type: Array,
      required: true
    }
  },
  filters: {
    currency
  },
  methods: {
    enterDetail (id) {
      this.$emit('click', id)
    },
    clickAddCart (item) {
      this.$emit('clickAddCart', item)
    }
  },
}
</script>

<style lang="scss" scoped>
.con {
  padding: 0;
}

h1 {
  margin: 20px 0 10px 0;
  img {
    width: 100%;
  }
}

.bottom {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  box-sizing: border-box;
  padding: 0 10px;
  padding-bottom: 60px;
  justify-content: space-between;
  .con {
    width: 49%;
    box-sizing: border-box;

    margin-bottom: 5px;
    background-color: #fff;
    border-radius: 5px;

    img {
      width: 100%;
      height: 150px;
      border-radius: 5px 5px 0 0;
    }
    .c-bttom {
      box-sizing: border-box;
      padding: 0 5px;
      p {
        font-size: 14px;
        color: #333;
        font-weight: 550;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        line-height: 20px;
      }
      .evaluate {
        width: 70px;
        height: 10px;
        font-size: 10px;
        text-align: center;
        line-height: 10px;
        border-radius: 2px;
        border: 1px solid #ffbb00;
        margin-top: 5px;
      }
      .price {
        margin: 10px 0;
        display: flex;
        align-items: center;
        justify-content: space-between;
        .money {
          font-size: 16px;
          color: red;
          font-weight: 550;
        }
        .volume {
          margin-left: 5px;
          color: #777;
        }
      }
    }
  }
}
</style>
